package triggerhelper.helperClasses;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JComboBox;

public class ComboListener implements ActionListener {
    private JComboBox combo;
    private Object currentItem;

    public ComboListener(JComboBox combo) {
        this.combo  = combo;
//        combo.setSelectedIndex(0);
        currentItem = combo.getSelectedItem();
    }

    public void actionPerformed(ActionEvent e) {
        Object tempItem = combo.getSelectedItem();
        if (!((ComboItem)tempItem).isEnabled()) {
            combo.setSelectedItem(currentItem);
        } else {
            currentItem = tempItem;
        }
    }
  }